package de.tabuma.pm.externalproject.view;

import de.tabuma.lib.tabumaview;
import de.tabuma.pm.*;
import de.tabuma.pm.externalproject.entity.*;
import de.tabuma.pm.externalproject.logik.*;
import java.io.PrintWriter;
import java.util.*;
import java.util.logging.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author alefen
 */
public class update extends tabumaview {

    public update(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }


    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        String next = "Next";
        String cancel = "Cancel";
        String projectUrl = "url";
        String projectName = "name";
        String projectParameter = "parameter";
        String post = "request";
        String post_get = "get method";
        String post_post = "post method";

        ExternalProject ep = (ExternalProject) request.getAttribute(constants.externalProject);

        String way1 = "Give login url with parameter list (comma seperated).  Mark parameter that were user based datas with $ f.e. username=$username";

        out.println("<div class=\"contentBoxed\">");
        out.println("<div class=\"contentContent\">");
        out.println("<p>"+way1+"</p>");
        out.println(this.getFormBeginn(null));
        out.println(this.getHiddenAsAttribute());
        out.println(printHiddenField(constants.externalProjectId, (String) request.getAttribute(constants.externalProjectId)));
        out.println(printHiddenField(constants.updateExternalProject1, "true"));

        out.println("<div class=\"cols\">");
        out.println(printForm1(projectName, constants.externalProjectName, (String) request.getAttribute(constants.externalProjectName)));
        out.println(printForm2(projectUrl, constants.externalProjectUrl, (String) request.getAttribute(constants.externalProjectUrl)));

        out.println(printForm1(projectParameter, constants.externalProjectParameter, (String) request.getAttribute(constants.externalProjectParameter)));
        out.println("<div class=\"col2\">");
        out.println("<div class=\"col2_head\">"+post+"</div>");
        out.println("<div class=\"col2_content\"><select name=\"" + constants.externalProjectPost + "\"><option value=\"" + constants.externalProjectPost_Get + "\">" + post_get + "</option><option value=\"" + constants.externalProjectPost_Post + "\" " + (ep.getPost()==Boolean.TRUE ? "selected" : "") + ">" + post_post + "</option></select></div>");
        out.println("</div>");

        out.println("<div class=\"col1\"></div>");
        out.println("<div class=\"col2\"></div>");
        out.println("</div>");

        out.println("<input type=\"submit\" class=\"button\" name=\""+constants.next+"\" value=\""+next+"\"/>");
        out.println("<input type=\"submit\" class=\"button\" name=\""+constants.cancel+"\" value=\""+cancel+"\"/>");
        out.println(this.getFormEnd());
        out.println("</div>");
        out.println("</div>");
    }

}
